package org.erepublik.company.thread;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.erepublik.company.EProductType;
import org.erepublik.company.product.Weapons;
import org.erepublik.company.scanner.WeaponScanner;

public class WeaponListener implements ServletContextListener {

    public void contextDestroyed(ServletContextEvent arg0) {
    }

    public void contextInitialized(ServletContextEvent arg0) {
        System.out.println("odpalam watek updatujacy bronie...");
        ProductUpdater<Weapons> tankUpdater = new ProductUpdater<Weapons>("tank", 1000*60*30, new WeaponScanner(EProductType.TANK));
        tankUpdater.start();
        
        ProductUpdater<Weapons> artUpdater = new ProductUpdater<Weapons>("artillery", 1000*60*30, new WeaponScanner(EProductType.ARTILLERY));
        artUpdater.start();
        
        ProductUpdater<Weapons> rifleUpdater = new ProductUpdater<Weapons>("rifle", 1000*60*30, new WeaponScanner(EProductType.RIFLE));
        rifleUpdater.start();
     
        ProductUpdater<Weapons> helicopterUpdater = new ProductUpdater<Weapons>("helicopter", 1000*60*30, new WeaponScanner(EProductType.HELICOPTER));
        helicopterUpdater.start();

    }

    public static void main(String[] args) {
        new WeaponListener().contextInitialized(null);
        System.out.println("kurwa");
    }
    
}